using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;
using MimeCloud.AssetManagement.Business.Interface;

namespace MimeCloud.AssetManagement.DataProvider.Sql.Entities
{
    [Table(Name="T_AssetMetaData")]
    public class AssetMetadata : IMetaData
    {
        public AssetMetadata()
        {
            _MetaKey = default(EntityRef<MetaKey>);
            _MetaValue = default(EntityRef<MetaValue>);
        }

        [Column(Name="AssetID_FK")]
        public int AssetID { get; set; }

        [Column(Name="AssetMetaData_IDPK",IsPrimaryKey=true,IsDbGenerated=true)]
        public int ID { get; set; }

        [Column(Name = "MetaKeyID_FK")]
        public virtual int MetaKeyID { get; set; }
        [Column(Name = "MetaValueID_FK")]
        public virtual int MetaValueID { get; set; }
        

        [Association(ThisKey = "MetaKeyID", OtherKey = "ID", Storage = "_MetaKey", DeleteOnNull = true, IsForeignKey = true)]
        private MetaKey MetaKeyE { get { return _MetaKey.Entity; } set { _MetaKey.Entity = value; } }
        public IMetaKey MetaKey { get { return _MetaKey.Entity; } set { _MetaKey.Entity = value as MetaKey; } }
        internal EntityRef<MetaKey> _MetaKey;

        [Association(ThisKey = "MetaValueID", OtherKey = "ID", Storage = "_MetaValue", DeleteOnNull = true, IsForeignKey = true)]
        private MetaValue MetaValueE { get { return _MetaValue.Entity; } set { _MetaValue.Entity = value; } }
        public IMetaValue MetaValue { get { return _MetaValue.Entity; } set { _MetaValue.Entity = value as MetaValue; } }
        internal EntityRef<MetaValue> _MetaValue;
    }
}
